package function

import scala.Console.println

object Fun_Test {
  def main(args: Array[String]): Unit = {
    println(fun2()())
    println(res)
    val test = new Fun_Test
    println("两数相加：", test.oneAndTwo((test.add)))
    println("两束相减：", test.oneAndTwo((test.minus)))


  }

  def fun1(): String = {
    " 张三"
  }

  def fun2() = {
    fun1 _ //把函数作为值
  }

  def outFun(i: Int) = {
    def inFun(j: Int) = {
      i + j
    }

    inFun _ //把函数作为值
  }

  lazy val res = outFun(10)(10)


}

class Fun_Test {
  def oneAndTwo(fun: (Int, Int) => Int): Int = {
    fun(1, 2)
  }

  val add = (a: Int, b: Int) => a + b
  val minus = (a: Int, b: Int) => a - b

}
